package com.fjeld.middleware.activemq;

import com.fjeld.middleware.activemq.HeartbeatListener;
import com.fjeld.middleware.util.serverstatus.ServerStatusCapsule;
import com.fjeld.swingx.table.ObserverTableModel;

/**
 * Created by IntelliJ IDEA.
 * User: fjeld
 * Date: 28/12/2011
 * Time: 15:23
 * <p/>
 * Returns heartbeat specific data
 */
public class HeartbeatTableModel extends ObserverTableModel
{
    public HeartbeatTableModel()
    {
        super("Server", "Host", "Status");
    }

    @Override
    public Object getValueAt(int row, int col)
    {
        Object value = list.get(row);

        if (null != value)
        {
            ServerStatusCapsule ssc = (ServerStatusCapsule) value;
            ssc.addObserver(this);
            switch (col)
            {
                case 0: return ssc.getServerName();
                case 1: return ssc.getServerHostName();
                case 2: return ssc.getServerStatus();
                default: return "";
            }
        }

        return null;
    }


}
